(function() {
  var __hasProp = {}.hasOwnProperty,
    __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

  this.HomeView = (function(_super) {

    __extends(HomeView, _super);

    function HomeView() {
      return HomeView.__super__.constructor.apply(this, arguments);
    }

    HomeView.prototype.initialize = function() {
      HomeView.__super__.initialize.apply(this, arguments);
      this.setElement($('#main'));
      this.model.bind("change", this.render);
      return this.model.fetch();
    };

    HomeView.prototype.events = {
      "click .best-books-content ul.star-rating li a": "rate"
    };

    HomeView.prototype.rate = function(e) {
      var rating, ratingModel, ratingView, ul;
      e.preventDefault();
      rating = $(e.currentTarget);
      ul = rating.closest("ul.star-rating:not(.disabled)");
      if (ul.length > 0) {
        ratingModel = new RatingModel();
        ratingModel.set({
          "BookId": ul.data("val-bookid"),
          "RatingValue": rating.data("rate-value")
        });
        ratingView = new RatingView({
          model: ratingModel,
          el: $(ul)
        });
        return ratingView.render();
      }
    };

    HomeView.prototype.render = function() {
      var _this = this;
      return this.GetTemplate(SiteMap.Home.IndexTemplate, function(compiledTemplate) {
        return $(_this.el).html(compiledTemplate(_this.model.toJSON()));
      });
    };

    return HomeView;

  })(CustomView);

}).call(this);
